package simpleFactory;/*
 * @auther 顶风少年
 * @mail dfsn19970313@foxmail.com
 * @date 2019-07-24 10:06
 * @notify
 * @version 1.0
 */

import junit.framework.TestCase;

public class SimPleFactoryTest extends TestCase {
    public void testCreate() throws BadFruitException {
        Fruit apple = FruitGardener.factory("apple");
        assertTrue(apple instanceof Apple);

        Fruit grape = FruitGardener.factory("grape");
        assertTrue(grape instanceof Grape);

        Fruit strawberry = FruitGardener.factory("strawberry");
        assertTrue(strawberry instanceof Strawberry);
    }

    public void testExcetpion() {
        try {
            Fruit apple = FruitGardener.factory("banana");
        } catch (BadFruitException e) {
            assertTrue(e instanceof BadFruitException);
        }
    }


}
